<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      v-show="showSearch"
      label-width="98px"
    >
      <el-form-item label="裁判员名称" prop="refereesName">
        <el-input
          v-model="queryParams.refereesName"
          placeholder="请输入裁判员名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
      </el-form-item>
    </el-form>

    <table v-for="(item, index) in fereesList" :key="index" class="tabless">
      <div class="divfecsss">
        <ul>
          <li>
            <strong>
              <spn>裁判姓名:</spn>
              {{ item.refereesName }}
            </strong>
          </li>
  
          <!--   <li>裁判ID:{{ item.refereesUid }} &nbsp;</li> -->

          <li>
            <strong>
              <spn>裁判头像:</spn>
              <img
                :src="item.refereesphoto"
                style="width: 150px; height: 150px"
                class="img-circle img-lg"
              />
            </strong>
          </li>

          <li>
            <strong>
              <spn>裁判类型:</spn>
              {{ item.refereesXmType }}
            </strong>
          </li>

          <li>
            <strong>
              <spn>备注:</spn>
              {{ item.remark }}
            </strong>
          </li>
        </ul>
      </div>
    </table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<style scoped>
spn {
  color: rgb(14, 62, 150);
}
.divfecsss {
  position: relative;
  width: 1030px;
  height: 200px;
  border: 1px solid rgb(39, 143, 129);
}

.divfecsss ul {
  height: 200px;
  display: flex;
  flex-direction: row;
  justify-content: center;
}

.divfecsss ul li {
  list-style: none;
  height: 200px;
  line-height: 200px;
}
</style>

<script>
import { getToken } from "@/utils/auth";
import {
  listFerees,
  getFerees,
  delFerees,
  addFerees,
  updateFerees,
  Fereesavatar,
} from "@/api/sportferees/ferees";

export default {
  name: "Ferees",
  data() {
    return {
      fileList: [],
      url: "",
      sortList: [], //图片数组
      refereesphotolist: null, //赋值
      //refereesphoto: "", //裁判员头像
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 裁判员表格数据
      fereesList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        refereesXmName: null,
        refereesName: null,
        refereesXmType: null,
        refereesStatus: null,
        refereesphoto: null, //裁判员头像
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {},
    };
  },

  created() {
    this.getList();
  },
  methods: {
    //上传预处理
    beforeUpload(file) {
      //判断上传大小不大于5M
      const isLt5M = file.size / 1024 / 1024 < 5;
      if (!isLt5M) {
        this.$message.error("上传图片大小不能超过5MB!");
        return false;
      }
      let fileName = file.name;
      let uid = file.uid;
      let pos = fileName.lastIndexOf(".");
      let lastName = fileName.substring(pos, fileName.length);
      if (
        lastName.toLowerCase() !== ".png" &&
        lastName.toLowerCase() !== ".jpg"
      ) {
        this.msgError("文件必须为 .png .jpg");
        return false;
      }
    },
    uploadDemo(data) {
      let formData = new FormData();
      formData.append("refereesphoto", data.file);
      Fereesavatar(formData).then((response) => {
        // this.refereesphotolist=response.refereesphoto
        this.form.refereesphoto =
          process.env.VUE_APP_BASE_API + response.refereesphoto;
        //this.url=process.env.VUE_APP_BASE_API+this.form.refereesphoto;
        // this.form.refereesphoto = response.refereesphoto;
      });
    },

    /** 查询裁判员列表 */
    getList() {
      this.loading = true;
      listFerees(this.queryParams).then((response) => {
        console.log(response.rows);
        this.fileList.length = 0;
        for (let i = 0; i < response.rows.length; i++) {
          this.fileList.push(response.rows[i].refereesphoto);
          //this.sortList =response.rows[i].refereesphoto
        }
        //  console.log(this.fileList);

        this.fereesList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        refereesUid: null,
        refereesXmUid: null,
        refereesXmName: null,
        refereesphoto: null, //裁判员头像
        refereesName: null,
        refereesLevel: null,
        refereesXmType: null,
        refereesStatus: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        remark: null,
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
  },
};
</script>


